package project.layer.ant;

import framework.layer.agent.Agent;
import project.layer.physical.Crossroad;
import project.layer.physical.Road;

public abstract class HoppingAnt extends Ant {

	private int maxHops;
	private int currentHopCount = 0;
	private Road lastRoad = null;
	private long travelledDistance = 0;
	
	public int getMaxHops() {
		return maxHops;
	}

	public int getCurrentHopCount() {
		return currentHopCount;
	}

	public HoppingAnt(Agent sendingAgent, Crossroad location, int maxHops){
		super(sendingAgent,location);
		this.maxHops = maxHops;

	}
	
	public HoppingAnt(Agent sendingAgent, Crossroad location, int maxHops, int currentHopCount, Road lastRoad, long travelledDistance){
		super(sendingAgent,location);
		this.maxHops = maxHops;
		this.currentHopCount = currentHopCount;
		this.lastRoad = lastRoad;
		this.travelledDistance = travelledDistance;
	}
	
	@Override
	public abstract void processAntTick() ;
	
	public abstract void cloneAndSpread();
	
	public int getRemainingHops(){
		return maxHops - currentHopCount;
	}
	public void increaseHopCount(){
		currentHopCount++;
	}
	public void setTravelledDistance(long travelledDistance) {
		this.travelledDistance = travelledDistance;
	}
	public long getTravelledDistance(){
		return this.travelledDistance;
	}
	protected void increaseTravelledDistance(long distance) {
		this.travelledDistance += distance;
	}
	protected Road getLastRoad() {
		return lastRoad;
	}

	protected void setLastRoad(Road lastRoad) {
		this.lastRoad = lastRoad;
	}
	protected long getLengthOfLastRoad() {
		if(this.lastRoad != null)
			return this.lastRoad.getLength();
		return 0;
	}
	protected boolean equalsRoadLastTraveled(Road road) {
		if(getLastRoad() == null){
			return false;
		}else{
			return this.lastRoad.equals(road);
		}
		
		
	}
	

}
